import 'package:flutter/material.dart';
import 'package:flutter_app_05/widget/switch.dart';

class Guanjing extends StatefulWidget{
  @override
  GuanjingPageState createState() => new GuanjingPageState();


}

class GuanjingPageState extends State<Guanjing>{
  PageController mPageController = PageController(initialPage: 0);
  final List<Widget> pages = [
    Container(
      width: 100,
      height: 100,
      color: Colors.pinkAccent[100],
    ),
    Container(
      color: Colors.blueAccent[200],
    )
  ];
  @override
  Widget build(BuildContext context) {
    return Container(
     width: 300,
        height: 120,
        child: Column(
        children: [
          Container(
            width: 10,
            height: 10,
            child:  PageView.builder(
              itemCount: 2,
              controller: mPageController,
              onPageChanged: (index) {
                setState(() {});
              },
              itemBuilder: (BuildContext context, int index) {
                return pages[index];
              },
            ),
          ),

          SwitchButton(
            width: 250,
            height: 40,
            controller: mPageController,
            tabs: ['循环泵', '补水泵'],
            selectColor: Colors.green,
            unSelectColor: Colors.white70,
            currentIndex: mPageController.hasClients ?mPageController.page?.round(): mPageController.initialPage,
          )
      ],
    )


    );
  }


}